#!/usr/bin/python

import math

DIM = 20
SAFE_DISTANCE = math.sqrt(4*4 + 4*4)

def robber_move(rob, cop1, cop2, cop3):
   cops = [[cop1, distance_pyth(rob, cop1)],
         [cop2, distance_pyth(rob, cop2)],
         [cop3, distance_pyth(rob, cop3)]]

   smallest_distance = min(cops[0][1], cops[1][1], cops[2][1])

   if smallest_distance > SAFE_DISTANCE:
      robber_perform_step(rob, step_towards(rob, [DIM/2,DIM/2]))
   elif smallest_distance == math.sqrt(2) or smallest_distance == 1:
      for cop in cops:
         if cop[1] == smallest_distance:
            robber_perform_step(rob, step_towards(rob, cop[0]))
   else:
      avg = avarage_position(cop1, cop2, cop3)
      robber_perform_step(rob, step_away(rob, avg))

def distance_pyth(unit1, unit2):
   return math.sqrt(
      math.pow(unit1[0] - unit2[0], 2) + math.pow(unit1[1] - unit2[1], 2)
   )

def avarage_position(unit1, unit2, unit3):
   return [(unit1[0] + unit2[0] + unit3[0]) / 3,
         (unit1[1] + unit2[1] + unit3[1]) / 3]

def step_towards(unit, target):
   dist_x = target[0] - unit[0]
   dist_y = target[1] - unit[1]

   if (dist_x == 0 and dist_y == 0):
      return [0, 0]
   elif (abs(dist_x) == abs(dist_y)):
      return [math.copysign(1, dist_x), math.copysign(1, dist_y)]
   elif (abs(dist_x) > abs(dist_y)):
      return [math.copysign(1, dist_x), 0]
   else:
      return [0, math.copysign(1, dist_y)]

def step_away(unit, target):
   dist_x = target[0] - unit[0]
   dist_y = target[1] - unit[1]

   if (dist_x == 0 and dist_y == 0):
      return [0, 0]
   elif (abs(dist_x) == abs(dist_y)):
      return [-math.copysign(1, dist_x), -math.copysign(1, dist_y)]
   elif (abs(dist_x) > abs(dist_y)):
      return [-math.copysign(1, dist_x), 0]
   else:
      return [0, -math.copysign(1, dist_y)]

def robber_perform_step(rob, d):
   print '{0:d} {0:d}'.format(int(rob[0]+d[0]),int(rob[1]+d[1]))


robber_move([19, 19], [0, 0], [0, 0], [0, 0])